#include "SnowChains.h"
#include "robotmap/robotmap.h"
#include <iostream>

SnowChains::SnowChains(RobotMap* robotmap)
{
    _map = robotmap ;
}

void SnowChains::moveUp()
{
    Coord position = _map->position() ;
	if (position.second != 1 && _map->ressourceString(position.first, position.second-1) == "Neige")
    {
        _map->moveUp();
    }
}

void SnowChains::moveDown()
{
    Coord position = _map->position() ;
    if (position.second != _map->mapViewer()->map()->height() &&
            _map->ressourceString(position.first, position.second+1) == "Neige")
    {
		_map->moveDown();
    }
}

void SnowChains::moveLeft()
{
    Coord position = _map->position() ;
    if (position.first != 1 && _map->ressourceString(position.first-1, position.second) == "Neige")
    {
		_map->moveLeft();
    }
}

void SnowChains::moveRight()
{
	Coord position = _map->position() ;
	std::cout << _map->ressourceString(position.first+1, position.second) << std::endl ;
    
    if (position.first != _map->mapViewer()->map()->width()
            && _map->ressourceString(position.first+1, position.second) == "Neige")
    {
		_map->moveRight();
    }
}

